//
//  MZViewController.m
//  MZBasic
//
//  Created by YCMZ on 05/16/2019.
//  Copyright (c) 2019 YCMZ. All rights reserved.
//

#import "MZViewController.h"
#import <BaseRegisterModel.h>
#import "MZViewController2.h"
#import <BZTheme.h>
#import <BZThemeMacor.h>
//#import <MZBasic.h>
#import "MZView.h"
#import "MZExColor.h"
#import "MZAppDelegate.h"
#import <objc/runtime.h>
#import <objc/message.h>


@interface MZViewController ()

@property (nonatomic, strong) UIView *v;

@property (nonatomic, strong) MZExColor *color;

@end

@implementation MZViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    
//    [[BZThemeManager sharedInstance] switchTheme:[[BZThemeDefaultExample alloc] init]];
    __weak typeof(self) weakSelf = self;
//    BZThemeBlock(self.view, ^{
//        weakSelf.view.backgroundColor = BZTHEME_COLOR(skin_page_bg_color);
//    });
    
    BZTHEME_COLOR(skin_page_bg_color,self.view,backgroundColor);

    
//    BZTHEME_COLOR(skin_page_bg_color, self.view, backgroundColor);
//    self.view.backgroundColor = BZTHEME_COLOR(skin_page_bg_color);
    
    
    
    MZView *vLeft = [[MZView alloc] init];
    vLeft.frame = CGRectMake(50, 100, 150, 80);
    BZTHEME_COLOR(skin_content_bg_color,vLeft,backgroundColor);
    [self.view addSubview:vLeft];
    
    UIView *vLine = [[UIView alloc] init];
    vLine.frame = CGRectMake(200, 100, 1, 80);
    BZTHEME_COLOR(skin_line_color,vLine,backgroundColor);
    [self.view addSubview:vLine];
    
    UIView *vRight = [[UIView alloc] init];
    vRight.frame = CGRectMake(201, 100, 150, 80);
    BZTHEME_COLOR(skin_content_bg_color,vRight,backgroundColor);
    [self.view addSubview:vRight];
    
    UIView *vLine1 = [[UIView alloc] init];
    vLine1.frame = CGRectMake(50, 180, 300, 1);
    BZTHEME_COLOR(skin_line_color,vLine1,backgroundColor);
    [self.view addSubview:vLine1];
    
    UIButton *btnSwitch = [UIButton buttonWithType:UIButtonTypeCustom];
//    BZTHEME_COLOR(skin_main_color,btnSwitch,backgroundColor);
    BZTHEME_SEL(self, @selector(updata));
    
    BZTHEME_BLOCK(btnSwitch, ^{
        NSLog(@"block1");
    });
    UIImage *img = BZTHEME_IMAGE(skin_order_bottom_copy_img);
    img = [img imageWithRenderingMode:(UIImageRenderingModeAlwaysTemplate)];
    __weak typeof(btnSwitch) weakBtn = btnSwitch;
//    BZThemeBlock(btnSwitch, ^{
//        NSLog(@"block2");
//        [weakBtn setTitleColor:BZTHEME_COLOR(skin_main_color) forState:UIControlStateNormal];
//        [weakBtn setTitleColor:BZTHEME_COLOR(skin_textfield_placeholder_color) forState:UIControlStateSelected];
//    });
    
    [btnSwitch addTarget:self action:@selector(switchAction:) forControlEvents:UIControlEventTouchUpInside];
//    [btnSwitch setTitle:@"切换" forState:UIControlStateNormal];
    [btnSwitch setImage:img forState:UIControlStateNormal];
    [btnSwitch setBackgroundImage:img forState:UIControlStateNormal];
    btnSwitch.tintColor = BZTHEME_COLOR(skin_main_color);
    btnSwitch.imageView.tintColor = BZTHEME_COLOR(skin_mask_color);
    btnSwitch.titleLabel.textColor = [UIColor whiteColor];
    btnSwitch.frame = CGRectMake(50, 181, 300, 50);
    [self.view addSubview:btnSwitch];
    
    UIImageView *imvImage = [[UIImageView alloc] initWithFrame:CGRectMake(50, 236, 50, 50)];
//    UIImage *img = BZTHEME_IMAGE(skin_order_bottom_copy_img);
    
    [imvImage BZTheme_tintColorImage:img StrTintColorKey:skin_main_color];
    [self.view addSubview:imvImage];
    
}

- (void) updata {
    NSLog(@"yanseshuax");
}


- (void) switchAction:(UIButton *) btn {
    btn.selected = !btn.selected;
    if (btn.selected) {
//        [[BZThemeManager sharedInstance] switchTheme:[[BZThemeDynamicExample alloc] init]];
    }else {
//        [[BZThemeManager sharedInstance] switchTheme:[[BZThemeDefaultExample alloc] init]];
    }
    
    
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    
}

@end
